{if ($_GPC['do'] == 'tuser' || $_GPC['do'] == 'tuserphotos') && !empty($tfrom_user)}
	
	<div style="  position: fixed;  bottom: 200px;  width: 65px;  height: 65px;  z-index: 10000;  right: 10px; display:none;" onclick="ewm();">
		<img src="../addons/fm_photosvote/template/mobile/photos/ewm.png" width="65" style="border-radius:100px;">
	</div>
	<div class="modal fade" id="ewmdisplay" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="  margin-top: 60px;z-index:1000000">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					<h4 class="modal-title text-danger">{if $from_user == $tfrom_user}我{else}{if $user['realname']}{$user['realname']}{else}{$user['nickname']}{/if}{/if}的专属二维码</h4>
				</div>	
				<div class="modal-body ewmbg" style="  background: #F9F9F9;">
					<div class="form-group">							
						<div style="text-align:center; background-color: transparent;" id = "ewmcode">
							<span class="text-info tishi">{if $user['ewm']}正在生成{else}第一次生成会比较慢，请耐心等待{/if}
							<p><img src="../addons/fm_photosvote/template/mobile/photos/ajax-loader.gif" width="50"></p>
							</span>
						</div>
					</div>
					<div class="form-group">							
						<div class="text-danger sys" style="text-align:center; background-color: transparent;  font-size: 20px;display:none">
							<strong>赶紧扫一扫，为我投一票吧！</strong>
						</div>
					</div>

				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
{/if}

 <div class="geetest">
    <div class="bg"></div>
    <div class="wrap">
      <div class="top">
        <a class="exit" id="close" href="javascript:;"></a>
        <div class="title">
          请滑动验证
        </div>
      </div>		
		<script type="text/javascript" src="http://api.geetest.com/get.php?gt={$reply['codekey']}&width=300" async></script>
    </div>
	
  </div>

<style>
  .geetest {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
	z-index:9999999999;
  }
  .bg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    opacity: 0.7;
  }
  .wrap {
    width: 300px;
    margin: 10px auto;
    text-align: center;
    background-color: #fff;
    z-index: 2;
    position: relative;
	 top: 20%;
  }
  .gt_wrapper {
    margin: 0 auto;
  }
  .wrap .top {
    padding: 0 8px;
    height: 44px;
    z-index: 1;
    position: relative;
    text-align: center;
    font-weight: 500;
  }

  .wrap .title {
    line-height: 45px;
    width: 200px;
    margin: 0 auto;
  }

  .exit {
    background-image: url('../addons/fm_photosvote/api/validate/img/return_hover.png');
    -moz-background-size: 12px auto;
    -o-background-size: 12px auto;
    -webkit-background-size: 12px auto;
    background-size: 12px auto;
    width: 12px;
    height: 22px;
    display: inline-block;
    vertical-align: middle;
    position: absolute;
    left: 8px;
    top: 11px;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    z-index: 10;
  }
  .exit:active {
    background-image: url('../addons/fm_photosvote/api/validate/img/return_hover.png');
  }
</style>

<div class="modal fade" id="subsribe" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="  margin-top: 60px;">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
				<h4 class="modal-title">关注 {$_W['account']['name']}</h4>
			</div>	
				<div class="modal-body">
					<div class="form-group">							
						<div style="text-align:center; background-color: transparent;" id = "ewmcode">
							<div style="word-break: break-all;width:100%">{if !empty($reply['subscribedes'])}{$reply['subscribedes']}{else}请长按二维码关注或点击“关注投票”，前往{$_W['account']['name']}为您的好友投票。如已关注，请关闭此对话框，为Ta点赞或拉票。{/if}</div>
						</div>
					</div>
					<div class="form-group">							
						<div style="text-align:center; background-color: transparent;" id = "ewmcode">
							<a href="{$reply['shareurl']}"><img src="{$_W['attachurl']}qrcode_{$_W['acid']}.jpg?{php echo time()}" class="img-rounded" style="cursor:pointer; text-align: center;width:150px;" /></a>
						</div>
					</div>
					<div class="form-group">							
						<div style="text-align:center; background-color: transparent;  font-size: 20px;">
							<a href="{$reply['shareurl']}" class="btn btn-info" style='color:#fff;width:100%'>关注</a>
							<strong></strong>
						</div>
					</div>

				</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<div class="modal fade" id="fminfo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="  margin-top: 60px;z-index:1000000000">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
				<h4 class="modal-title text-info">系统提示</h4>
			</div>	
			<div class="modal-body">
				<div class="form-group">							
					<div style="text-align:center; background-color: transparent;" class=" text-info" id = "fminfotext"></div>
				</div>
				<div class="form-group huodongt"  style="display:none;" >							
					<div style="text-align:left; background-color: transparent;" >
						<h3 style="font-size:16px;">抽奖去 👇</h3>
					</div>
				</div>

				{if $_GPC['do'] == 'photosvoteview' || $_GPC['do'] == 'tuser'|| $_GPC['do'] == 'tuserphotos' }
				
					{if !empty($huodong) && !empty($huodong['huodongname']) && !empty($huodong['hhhdpicture']) && ($huodong['ishuodong'] == 1 && !empty($huodong['huodongurl'])) }
						
						<div class="form-group huodong"  style="display:none;background:#EC4933;height:50px;line-height:50px;">
							<a href="{$huodong['huodongurl']}&from=fm_photosvote&oid={$from_user}"  >
							<div style="width:50px;height:50px;overflow:hidden;margin-right:20px;margin-left:10px;float:left;">
								<img src="{php echo toimage($huodong['hhhdpicture'])}" width="50" style="">
							</div>						
							<div style="text-align:left; background-color: transparent;color:#fff;font-size:15px;" class=" text-info">
								{$huodong['huodongname']}
							</div>
							</a>
						</div>
						
					{/if}
				{/if}
			</div>
			<div class="modal-footer" style="  text-align: center;">
				<button type="button" class="btn btn-info" data-dismiss="modal">关闭</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>

function fminfo(text) {
	$('#fminfo').modal('toggle');
	$('#fminfotext').html(text);
}
function ewm() {
	$('#ewmdisplay').modal('toggle');
	
	$.post("{php echo $this->createMobileUrl('qrcode', array('url' => $url, 'tid' => $user['uid']))}", function(data) {
		if (data.success == true) {
			$('.tishi').hide();
			$('.sys').show();
			$('#ewmcode').html('<img width="100%" src="'+ data.linkurl +'" alt="{$user['nickname']}" title="{$user['realname']}"/>');
			return 
		} else {
			fminfo(data.msg);
			$('#ewmcode').html('<span class="text-danger">' + data.msg + '</span>');
			return 
		}
	},"json")
}

function tvote() {
	var iscode = "{$reply['iscode']}";
	var now = "{$now}";
	var tstart_time = "{$reply['tstart_time']}";
	var tend_time = "{$reply['tend_time']}";
	var ttipstart = "{$reply['ttipstart']}";
	var ttipend = "{$reply['ttipend']}";
	var votetime = "{$reply['votetime']}";
	var ttipvote = "{$reply['ttipvote']}";
	var ucreatetime = "{$user['createtime']}";
	var subscribe = "{$reply['subscribe']}";
	var follow = "{$follow}";
	var tfrom_user = "{$tfrom_user}";
	var vfrom = "{$vfrom}";
	var isdaojishi = "{$reply['isdaojishi']}";
	
	var votetime = votetime*3600*24;
	var isvtime = now - ucreatetime;
	if (isdaojishi == 1) {

		if(isvtime >= votetime) {					
			//u.message(ttipvote, '', 'success');		
			fminfo(ttipvote);
			return false;
		}
	}

	if (now <= tstart_time) {
		//u.message(ttipstart, '', 'success');		
		fminfo(ttipstart);
		return false;
	}
	if (now >= tend_time) {
		//u.message(ttipend, '', 'success');	
		fminfo(ttipend);
		return false;
	}
	if (iscode == 1) {
		if (subscribe == 1) {
			if (follow == 1) {
				tvotestart(tfrom_user, vfrom, iscode);
			}else{
				 subsribe();
			}
		}else{
			tvotestart(tfrom_user, vfrom, iscode);
		}
	}else {
		if (subscribe == 1) {
			if (follow == 1) {				
				tvotestart(tfrom_user, vfrom, iscode);
			}else{
				subsribe();
			}
			
		}else {
			tvotestart(tfrom_user, vfrom, iscode);
		}
	}
}

function tvotestart(tfrom_user, vfrom, iscode) {
	
	{if !empty($reply['iplocallimit']) && ($_GPC['do'] == 'photosvoteview' || $_GPC['do'] == 'tuser'|| $_GPC['do'] == 'tuserphotos') }
		var tdw = sessionStorage.getItem("dw");
		if (!tdw) {
			var userlocal = sessionStorage.getItem("userlocal");
			var diqu = sessionStorage.getItem("diqu");
			var stoplocal = '{php echo $this->createMobileUrl('stopip', array('rid'=> $rid, 'iptype' => 'local'))}&nowlocal=' + userlocal + "&diqu=" + diqu;
			window.location.href = stoplocal;
			return false;
		}
	{/if}
	
	if (iscode == 1) {
		var qs = function(e) {
		  return document.querySelector(e);
		};
		//var button = document.getElementById("tvote");

		var geetest = qs(".geetest");
		//button.onclick = function() {
		  geetest.style.display = "block";
		//};
		var close = document.getElementById("close");
		close.onclick = function() {
		  geetest.style.display = "none";
		};
		qs(".bg").onclick = function() {
		  geetest.style.display = "none";
		};
		window.gt_custom_ajax = function(result, id, message) {
			if(result) {										
				var submitData = {
					message: message,
					tfrom_user: tfrom_user,
					vfrom: vfrom
				};
				$.post("{php echo $this->createMobileUrl('Tvotestart', array('vote' => '1', 'rid' => $rid))}", submitData, function(data) {	
					//geetest.style.display = "none";

					qs('#' + id).parentNode.parentNode.style.display = "none";
					if (data.success == true) {
						fminfo(data.msg);
						
							{if !empty($huodong) && !empty($huodong['huodongname']) && !empty($huodong['hhhdpicture']) && ($huodong['ishuodong'] == 1 && !empty($huodong['huodongurl'])) }
								$(".huodongt").show();
								$(".huodong").show();
							{else}
								setTimeout(function () {								
									window.location.reload();
								},3000)
							{/if}
						return 
						
					} else {
						if (data.success == -1) {
							fminfo(data.msg);
							setTimeout(function () {								
								window.location.reload();
							},3000)
							return 
						}
						if (data.success == 3) {
							fminfo(data.msg);
							setTimeout(function () {								
								window.location.href = data.linkurl;
							},1000)	
							return
						}
						if (data.success == 9) {
							//windows.location.href = data.msg;
							 window.location.href = "{$reply['shareurl']}";
						}
					}
				},"json")
			}
		}
	}else {
		var submitData = {
			tfrom_user: tfrom_user,
			vfrom: vfrom
		};
		$.post("{php echo $this->createMobileUrl('Tvotestart', array('vote' => '1', 'rid' => $rid))}", submitData, function(data) {
			if (data.success == true) {
				fminfo(data.msg);
				
				{if !empty($huodong) && !empty($huodong['huodongname']) && !empty($huodong['hhhdpicture']) && ($huodong['ishuodong'] == 1 && !empty($huodong['huodongurl'])) }
					$(".huodongt").show();
					$(".huodong").show();
				{else}
					setTimeout(function () {								
					window.location.reload();
					},3000)
				{/if}
				
				return 
				
			} else {
				if (data.success == -1) {
					fminfo(data.msg);
					setTimeout(function () {								
						window.location.reload();
					},3000)
					return 
				}
				if (data.success == 3) {
					fminfo(data.msg);
					setTimeout(function () {								
						window.location.href = data.linkurl;
					},1000)	
					return
				}
				if (data.success == 9) {
					//windows.location.href = data.msg;
					 window.location.href = "{$reply['shareurl']}";
				}
			}
		},"json")
	}
	
}


function bbsreply(content, iscode, bbstype) {
	if (iscode == 1) {
		var qs = function(e) {
		  return document.querySelector(e);
		};
		//var button = document.getElementById("tvote");

		var geetest = qs(".geetest");
		//button.onclick = function() {
		  geetest.style.display = "block";
		//};
		var close = document.getElementById("close");
		close.onclick = function() {
		  geetest.style.display = "none";
		};
		qs(".bg").onclick = function() {
		  geetest.style.display = "none";
		};
		window.gt_custom_ajax = function(result, id, message) {
			if(result) {									
				var submitData = {
					content: content
				};
				$.post("{php echo $this->createMobileUrl('Tbbsreply', array('isbbsreply' => '1', 'tfrom_user' => $tfrom_user, 'rid' => $rid))}", submitData, function(data) {
					//qs('#' + id).parentNode.parentNode.style.display = "none";
					geetest.style.display = "none";
					if (data.success == true) {														
						//u.message(data.msg, '', 'success');	
						if (bbstype == 'bbsreply') {
							fminfo(data.msg);
							setTimeout(function () {								
								window.location.reload();
							},3000)	
						}
						
						return 
						
					} else {
						
						if (data.success == -1) {
							//$("#result_info_tip").text(data.msg);	
							//u.message(data.msg, '', 'error');	
							fminfo(data.msg);
							return 
						}
						
						if (data.success == 3) {
							//windows.location.href = data.linkurl;	
							fminfo(data.msg);
							setTimeout(function () {								
								window.location.href = data.linkurl;
							},1000)	
							return
						}
					}
				},"json")
			}
		}
	}else {
		var submitData = {
			content: content
		};
		$.post("{php echo $this->createMobileUrl('Tbbsreply', array('isbbsreply' => '1', 'tfrom_user' => $tfrom_user, 'rid' => $rid))}", submitData, function(data) {
			if (data.success == true) {														
				//u.message(data.msg, '', 'success');	
				if (bbstype == 'bbsreply') {
						fminfo(data.msg);
						setTimeout(function () {								
							window.location.reload();
						},3000)	
					}
				return 
			} else {
				
				if (data.success == -1) {
					//$("#result_info_tip").text(data.msg);	
					//u.message(data.msg, '', 'error');	
					fminfo(data.msg);
					return 
				}
				
				if (data.success == 3) {
					//windows.location.href = data.linkurl;	
					fminfo(data.msg);
					setTimeout(function () {								
						window.location.href = data.linkurl;
					},1000)	
					return
				}
			}
		},"json")
	}
	
}
function tvotep(tfrom_user,user) {
	var iscode = "{$reply['iscode']}";
	var now = "{$now}";
	var tstart_time = "{$reply['tstart_time']}";
	var tend_time = "{$reply['tend_time']}";
	var ttipstart = "{$reply['ttipstart']}";
	var ttipend = "{$reply['ttipend']}";
	var votetime = "{$reply['votetime']}";
	var ttipvote = "{$reply['ttipvote']}";
	var ucreatetime = $("#ucreatetime" + tfrom_user).val();
	var subscribe = "{$reply['subscribe']}";
	var follow = "{$follow}";
	var isdaojishi = "{$reply['isdaojishi']}";
	var vfrom = "photosvoteview";
	var votetime = votetime*3600*24;
	var isvtime = now - ucreatetime;
if (isdaojishi == 1) {
	if(isvtime >= votetime) {					
		//u.message(ttipvote, '', 'success');		
		fminfo(ttipvote);
		return false;
	}
}
	

	if (now <= tstart_time) {
		//u.message(ttipstart, '', 'success');		
		fminfo(ttipstart);
		return false;
	}
	if (now >= tend_time) {
		//u.message(ttipend, '', 'success');	
		fminfo(ttipend);
		return false;
	}
	
	if (iscode == 1) {
		if (subscribe == 1) {
			if (follow == 1) {			
				tvotestart(tfrom_user, vfrom, iscode);
			}else{
				subsribe();
			}
		}else{
			tvotestart(tfrom_user, vfrom, iscode);	
		}
	}else{
		if (subscribe == 1) {
			if (follow == 1) {
				tvotestart(tfrom_user, vfrom, iscode);
			}else{
				subsribe();
			}
		}else{
			tvotestart(tfrom_user, vfrom, iscode);
		}
	}
	
}
function getcode() {
	var pic = document.getElementById('getcodesrc');
	pic.src="{php echo $this->createMobileUrl('code');}&" + Math.random();
}
function subsribe() {
	$('#subsribe').modal('toggle');
}

	function getlocaltion() {
		
			wx.getLocation({
			    type: 'wgs84', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
			    success: function (res) {
			        var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
			        var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
			        var speed = res.speed; // 速度，以米/每秒计
			        var accuracy = res.accuracy; // 位置精度
					var location= latitude+"," + longitude;
					//百度接口，一天可以调用100w次
					var url="http://api.map.baidu.com/geocoder/v2/" + "?ak=2WUgR2cnnF4WGBVpNLzvS8HS&callback=renderReverse&location="+location+"&output=json&pois=0";
					$.ajax({
					      type : "get",
					      async:false,
					      url : url,
					      dataType : "jsonp",
					      jsonp: "callback",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
					      jsonpCallback:"renderReverse",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
					      success : function(json){
					      		
					          if (json.status=="0"){
					          	sessionStorage.setItem("getLocation", "{$reply["iplocallimit"]}"); 
					            var address=json.result.addressComponent;
					            var diqu="{$reply["iplocallimit"]}".split(",");
					            var str=address.province+","+address.city+","+address.district;
					          
					         	sessionStorage.setItem("userlocal", str); 
					         	sessionStorage.setItem("diqu", diqu); 
					            var dw=false;
					            $.each(diqu, function(i, item){ 
					                 if (str.indexOf(item)>-1) {
					                   dw=true;
					                   sessionStorage.setItem("dw", dw); 
					                   return false;
					                 }  
					             }); 
					          } else {
					            alert("获取定位失败");
					        }
					      },
					      error:function(){
					          alert('获取定位失败');
					      }
					  });


			    }
			});
		
	}
</script>